package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/4.
 */
@HttpInlet(Conn.API_INSURANCE_CARCC)
public class GetApiCarCc extends BaseAsyGet<GetApiCarCc.CarCcEntityList> {


    public GetApiCarCc(AsyCallBack<CarCcEntityList> asyCallBack) {
        super(asyCallBack);
    }


    @Override
    protected CarCcEntityList parser(JSONObject object) {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            CarCcEntityList carCcEntityList = new CarCcEntityList();

            JSONArray array = object.optJSONArray("data");

            for (int i = 0; i < array.length(); i++) {

                JSONObject entityObject = array.optJSONObject(i);

                CarCcEntity carCcEntity = new CarCcEntity();

                carCcEntity.id = entityObject.optString("id");
                carCcEntity.title = entityObject.optString("title");
                carCcEntity.money = entityObject.optString("money");

                carCcEntityList.listsCarCc.add(carCcEntity);

            }

            return carCcEntityList;

        }


        return null;


    }

    public static class CarCcEntityList {

        public List<CarCcEntity> listsCarCc = new ArrayList<>();

    }

    public static class CarCcEntity {

        public String id, title, money;

    }


}
